<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>基础数据管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="基础,数据,管理">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="queryBaseData.action" namespace="/inner/data/">
    		<s:hidden name="bvo.bd.parentId" id="parentId"></s:hidden>
    		<s:hidden name="beforePid" id="beforePid"></s:hidden>
    		
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'系统管理'},{'name':'数据管理'},{'name':'基础数据管理'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<table cellspacing="1" width="100%" bgcolor="#CCCCCC">
				<tr bgcolor="#FFFFFF">
					<td align="right" width="10%" class="label">
						键：
					</td>
					<td align="left" width="23%">
						<s:textfield name="bvo.bd.id" id="bdId" cssStyle="width:80%"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						值：
					</td>
					<td align="left" width="23%">
						<s:textfield name="bvo.bd.dataValue" id="dataValue" cssStyle="width:80%"></s:textfield>
					</td>
					<td width="34%"></td>
				</tr>
			</table>
    		
			<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
						<my:hasPermission privilegeId="searchBaseData">
						<input type="button" value="查询" class="btn" onclick="searchThis()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="addBaseData">
						<input type="button" value="新增" class="btn" onclick="toAddBaseData()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="delBaseData">
						<input type="button" value="删除" class="btn" onclick="delBaseData()"/>
						</my:hasPermission>
						<s:if test='!"0".equals(bvo.bd.parentId)'>
						<input type="button" value="返回" class="btn" onclick="backBaseData()"/>
						</s:if>
					</td>
				</tr>
			</table>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr class="tableHead" align="center">
    				<td width="10%">
    					<input type="checkbox" onclick="cbCheck(this, 'bdIds')" />
    				</td>
    				<td width="10%">
    					序号
    				</td>
    				<td width="25%">
    					键
    				</td>
    				<td width="25%">
    					值
    				</td>
    				<td width="15%">
    					排序
    				</td>
    				<td width="15%">
    					操作
    				</td>
    			</tr>
    			<s:iterator value="lp.list" status="s">
    				<tr align="center"
    					<s:if test="#s.index%2==0">class="tableRow2" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow2'"</s:if>
						<s:else>class="tableRow1" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow1'"</s:else>
    				>
    					<td>
    						<input name="bdIds" type="checkbox" value="<s:property value='id'/>" />
    					</td>
    					<td>
    						<s:property value="(pager.thisPage - 1) * pager.pageSize + #s.index + 1" />
    					</td>
    					<td>
    						<s:property value="id"/>
    					</td>
    					<td>
    						<a href="javascript:toChildren('<s:property value="id"/>')">
	    						<s:property value="dataValue"/>
	    						[<s:property value="childrenCount"/>]
    						</a>
    					</td>
    					<td>
    						<s:property value="sort"/>
    					</td>
    					<td>
    						<my:hasPermission privilegeId="updateBaseData">
    						<a href="javascript:toUpdateBaseData('<s:property value="id" />')">修改</a>
    						</my:hasPermission>
    					</td>
    				</tr>
    			</s:iterator>
   				<jsp:include page="/common/pager/pager.jsp">
					<jsp:param name="formName" value="frm" />
					<jsp:param name="id" value="1" />
				</jsp:include>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function searchThis()
    {
    	$('#thisPage').val(1);
    	document.forms['frm'].submit();
    }
    
    function toAddBaseData()
    {
    	var parentId = $('#parentId');
    	var url = '${CONTEXT_PATH}/inner/data/toAddBaseData.action?bd.parentId=' + parentId.val();
    	openWin(url, 650, 250);
    }
    
    function toUpdateBaseData(id)
    {
    	var url = '${CONTEXT_PATH}/inner/data/toUpdateBaseData.action?bd.id=' + id;
    	openWin(url, 650, 250);
    }
    
    function delBaseData()
    {
    	if(hasCheck('bdIds') == false)
    		return;
    	showConfirm('确认删除？', function(v){
    		if(v == true)
    		{
    			$.ajax({
		    		url:'${CONTEXT_PATH}/inner/data/delBaseDatas.action',
		    		type:'post',
		    		data:$("#frm").serialize(),
		    		success:
		    			function(result){
		    				document.forms['frm'].submit();
		    			}
		    	});
    		}
    	});
    }
    
    function toChildren(id)
    {
    	var parentId = $('#parentId');
    	var beforePid = $('#beforePid');
    	if(beforePid.val() == null)
    	{
    		beforePid.val('');
    	}
    	beforePid.val(beforePid.val() + ',' + parentId.val());
    	parentId.val(id);
    	document.forms['frm'].submit();
    }
    
    function backBaseData()
    {
    	var parentId = $('#parentId');
    	var beforePid = $('#beforePid');
    	var pids = beforePid.val().split(',');
    	var len = pids.length;
    	parentId.val(pids[len - 1]);
    	var index = beforePid.val().lastIndexOf(',');
    	var newBeforePid = beforePid.val().substring(0, index);
    	beforePid.val(newBeforePid);
    	document.forms['frm'].submit();
    }
    </script>
  </body>
</html>
